//
//  HepatitisBController.m
//  HarmonizePub
//
//  Created by rzhy on 2016/10/9.
//  Copyright © 2016年 Zy. All rights reserved.
//

#import "HepatitisBController.h"

@interface HepatitisBController ()

@property (weak, nonatomic) IBOutlet UILabel *resultText;
@property (weak, nonatomic) IBOutlet UISegmentedControl *oneSegmentedControl;
@property (weak, nonatomic) IBOutlet UISegmentedControl *twoSegmentedControl;
@property (weak, nonatomic) IBOutlet UISegmentedControl *threeSegmentedControl;
@property (weak, nonatomic) IBOutlet UISegmentedControl *fourSegmentedControl;
@property (weak, nonatomic) IBOutlet UISegmentedControl *fiveSegmentedControl;
@property (weak, nonatomic) IBOutlet UIButton *resultButton;

@end

@implementation HepatitisBController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"乙肝自测";
    self.resultButton.layer.cornerRadius = 5.0f;
    self.resultButton.layer.masksToBounds = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 查看结果
/**
 * I am not responsible of this code.
 * They made me write it, against my will.
 *
 * 下面的代码，我不负责。因为是他们逼我写的，违背了我的意愿.
 */
- (IBAction)seeResult:(UIButton *)sender {
    NSInteger oneValue = self.oneSegmentedControl.selectedSegmentIndex + 1;
    NSInteger twoValue = self.twoSegmentedControl.selectedSegmentIndex + 1;
    NSInteger threeValue = self.threeSegmentedControl.selectedSegmentIndex + 1;
    NSInteger fourValue = self.fourSegmentedControl.selectedSegmentIndex + 1;
    NSInteger fiveValue = self.fiveSegmentedControl.selectedSegmentIndex + 1;
    
    for (UIView *view in self.view.subviews)
        if (view != self.resultText)
            view.hidden = YES;
    
    if (oneValue == 2 && twoValue ==1 && threeValue == 1 && fourValue == 1 && fiveValue == 1 )
        self.resultText.text = [NSString stringWithFormat:@"您这种乙肝五项检查结果说明是急性乙肝病毒感染的潜伏期后期。"];
    else if (fiveValue == 2 && oneValue == 1 && twoValue == 1 && threeValue == 1 && fourValue == 1)
        self.resultText.text = [NSString stringWithFormat:@"您这种说明是乙肝病毒的隐性携带者或处于感染的窗口期，也说明曾经感染过乙肝病毒。"];
    else if (oneValue == 2 && threeValue == 2 && twoValue == 1 && fourValue == 1 && fiveValue == 1)
        self.resultText.text = [NSString stringWithFormat:@"您这种这种乙肝五项检查结果说明是急性乙肝的早期。"];
    else if (oneValue == 2 && fiveValue == 2 && twoValue == 1 && threeValue == 1 && fourValue == 1)
        self.resultText.text = [NSString stringWithFormat:@"您这种该乙肝五项结果说明感染过乙肝病毒，正在恢复期。"];
    else if (oneValue == 2 && threeValue == 2 && fiveValue == 2 && twoValue == 1 && fourValue == 1) 
        self.resultText.text = [NSString stringWithFormat:@"您这种俗称“大三阳”，这种乙肝五项结果情况说明是急、慢性乙肝。"];
    else if (oneValue == 2 && fourValue == 2 && fiveValue == 2 && twoValue == 1 && threeValue == 1)
        self.resultText.text = [NSString stringWithFormat:@"您这种俗称“小三阳”，说明是急、慢性乙肝。"];
    else if (fourValue == 2 && fiveValue == 2 && oneValue == 1 && twoValue == 1 && threeValue == 1)
        self.resultText.text = [NSString stringWithFormat:@"您这种该乙肝五项结果说明是急性乙肝病毒感染的恢复期，或曾经感染过乙肝病毒。"];
    else if (twoValue == 2 && fourValue == 2 && fiveValue == 2 && oneValue == 1 && threeValue == 1)
        self.resultText.text = [NSString stringWithFormat:@"您这种说明是乙肝的恢复期，已有免疫力。"];
    else if (twoValue == 2 && fiveValue == 2 && oneValue == 1 && threeValue == 1 && fourValue == 1 )
        self.resultText.text = [NSString stringWithFormat:@"您这种该乙肝五项结果说明是接种了乙肝疫苗后，或是乙肝病毒感染后已康复了，已有免疫力。"];
    else
        self.resultText.text=@"您这种乙肝五项说明正常，并无乙肝。";
    self.resultText.textAlignment = NSTextAlignmentLeft;
}

@end
